<?php

use kartik\helpers\Html;
use kartik\grid\GridView;

/* @var $this yii\web\View */
/* @var $searchModel backend\modules\logs\models\LogSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = '系统错误日志';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="log-index">

    <h1><?php // echo Html::encode($this->title) ?></h1>
    <?php // echo $this->render('_search', ['model' => $searchModel]); ?>

    <p>
        <?php // echo Html::a('Create Log', ['create'], ['class' => 'btn btn-success']) ?>
        <?php // echo Html::a('清空日志', ['delete-all'], ['class' => 'btn btn-warning', 'data-method' => 'post']) ?>
    </p>
    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'filterModel' => $searchModel,
        'columns' => [
//            ['class' => 'yii\grid\SerialColumn'],
            'id',
            'level',
            'category',
            [
                'attribute'=>'log_time',
                'format' => ['date', 'php:Y-m-d H:i:s'],
                'filterType' => \kartik\grid\GridView::FILTER_DATE_RANGE,
                'filterWidgetOptions' =>[
                    'model'=>$searchModel,
                    'attribute'=>'log_time',
                    'presetDropdown'=>TRUE,
                    'convertFormat'=>true,
                    'pluginOptions'=>[
                        'format'=>'Y-m-d',
                        'opens'=>'left',
                        'locale' => [
                            'cancelLabel' => 'Clear',
                            'format' => 'Y-m-d',
                        ],
                    ]
                ],
            ],
            'prefix:ntext',
            ['class' => \kartik\grid\ActionColumn::className()],
            [
                'class' => \kartik\grid\ExpandRowColumn::className(),
                'width' => '50px',
                'value' => function ($model, $key, $index, $column) {
                    return \kartik\grid\GridView::ROW_COLLAPSED;
                },
                'detail' => function ($model, $key, $index, $column) {
                    return Yii::$app->controller->renderPartial('message-detail', ['model'=>$model, 'id'=>$key]);
                },
                'headerOptions' => ['class' => 'kartik-sheet-style'],
                'expandOneOnly' => true,
                'pageSummary'=>'总计',//可以是字符串，当为true时，自动合计
            ],
//            'message',
            [
                'attribute' => 'message',
                /*'value' => function($model){
                    return '查看详细请打开左侧扩展按钮';
                },*/
                'headerOptions' => ['class' => 'kartik-sheet-style'],
//                'headerOptions' => ['width' => '10%'],
//                'contentOptions' => ['style' => 'max-width:800px;white-space: normal !important;max-height:18px;'],
            ],
        ],
    ]); ?>
</div>
